package com.br.android.widing.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.br.android.widing.R;
import com.br.android.widing.entity.Categoria;

public class ListCategoriaAdapter extends BaseAdapter {

	private Context context;
	private List<Categoria> listCats;

	public ListCategoriaAdapter(Context context, List<Categoria> listCats) {
		this.context = context;
		this.listCats = listCats;
	}

	@Override
	public int getCount() {
		return listCats.size();
	}

	@Override
	public Object getItem(int pos) {
		return listCats.get(pos);
	}

	@Override
	public long getItemId(int id) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Categoria categoria = listCats.get(position);
		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View view = inflater.inflate(
				R.layout.layout_adapter_list_cadastro_categorias, null);
		TextView tvCategoria = (TextView) view.findViewById(R.id.tvCategoria);
		tvCategoria.setText(categoria.getNomecategoria());
		return view;
	}

}
